package com.lykj.llw.box.adapter.home

import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.lykj.lib_base.component.GlideApp
import com.lykj.llw.box.R
import com.lykj.llw.box.data.bean.response.SearchRecommendResponse

/**
 * ================================================
 * 搜索推荐适配器
 * ================================================
 *
 * @author gosha
 * @date 2023/12/4-10:21
 */
class SearchRecommendAdapter :
    BaseQuickAdapter<SearchRecommendResponse.DataDTO, BaseViewHolder>(R.layout.item_search_recommend) {
    override fun convert(holder: BaseViewHolder, item: SearchRecommendResponse.DataDTO) {
        holder.setText(R.id.tv_name, "${item.gamename}")
        holder.setText(R.id.tv_summery, "${item.subject}")

        GlideApp.with(context)
            .load(item.icon)
            .transition(DrawableTransitionOptions.withCrossFade())
            .into(holder.getView(R.id.iv_icon))

        when (item.label) {
            1 -> {
                holder.setBackgroundResource(R.id.tv_tag, R.drawable.shape_bg_corner_3dp_tag_ff2c3f)
            }

            2 -> {
                holder.setBackgroundResource(R.id.tv_tag, R.drawable.shape_bg_corner_3dp_tag_3478f5)
            }

            3 -> {
                holder.setBackgroundResource(R.id.tv_tag, R.drawable.shape_bg_corner_3dp_tag_ffbe01)
            }
        }
    }
}